package com.api.base.controll;
import com.api.core.controller.Ctrl;
import com.api.core.response.Result;
import com.api.core.response.ResultGenerator;
import com.api.base.model.Menu;
import com.api.base.service.MenuService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
import com.api.core.annotation.PowerEnable;
import io.swagger.annotations.*;



/**
* Created by wanghuiwen on 2021/04/01.
*/
@PowerEnable(name = "菜单",url = "/menu")
@Api(value = "菜单", tags = {"菜单"})
@RestController
@RequestMapping("/menu")
public class MenuController extends Ctrl{
    @Resource
    private MenuService menuService;

    @ApiOperation(value = "菜单添加", tags = {"菜单"}, notes = "菜单添加")
    @PostMapping(value="/add",name="菜单添加")
    public Result add(@ApiParam Menu menu) {
        menuService.add(menu);
        return ResultGenerator.genSuccessResult();
    }

    @ApiOperation(value = "菜单删除", tags = {"菜单"}, notes = "菜单删除")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id",required=true, value = "菜单id", dataType = "Long", paramType = "query")
    })
    @PostMapping(value="/delete",name="菜单删除")
    public Result delete(@RequestParam Long id) {
        menuService.deleteById(id);
        return ResultGenerator.genSuccessResult();
    }


    @ApiOperation(value = "菜单列表", tags = {"菜单"}, notes = "菜单列表")
    @PostMapping(value="/list",name="菜单删除")
    public Result list() {
        return ResultGenerator.genSuccessResult( menuService.findAll());
    }



}
